package com.guidecaptain.java.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.guidecaptain.java.mapper.IncidentMapper;
import com.guidecaptain.java.model.pojo.Incident;
import com.guidecaptain.java.model.vo.IncidentVO;
import com.guidecaptain.java.service.IncidentService;

@Service("incidentService")
public class IncidentServiceImpl implements IncidentService {
	@Autowired
	private IncidentMapper incidentMapper;

	/**
	 * @param
	 * @return
	 */
	@Override
	public int insertIncident(Incident incident) {

		return incidentMapper.insertIncident(incident);
	}

	/**
	 * @param
	 * @return
	 */
	@Override
	public int deleteIncident(int incidentId) {

		return incidentMapper.deleteIncident(incidentId);
	}

	/**
	 * @param
	 * @return
	 */
	@Override
	public int updateIncident(Incident incident) {

		return incidentMapper.updateIncident(incident);
	}

	/**
	 * 查询是事件列表
	 * 
	 * @param
	 * @return
	 */
	@Override
	public List<IncidentVO> queryIncidentList(Incident incident) {
		List<IncidentVO> incidentVOs=incidentMapper.queryIncident(incident);
		return incidentVOs;
	}

	/**
	 * 根据事件ID查询
	 * 
	 * @param
	 * @return
	 */
	@Override
	public IncidentVO queryIncidentById(int incidentId) {
		Incident incident = new Incident();
		incident.setIncidentId(incidentId);
		List<IncidentVO> incidents = incidentMapper.queryIncident(incident);

		return incidents.size() <= 0 ? null : incidents.get(0);
	}

	/**
	 * 根据导游ID查询
	 * 
	 * @param
	 * @return
	 */
	@Override
	public List<IncidentVO> queryIncidentByGuideId(int guideId) {
		Incident incident = new Incident();
		incident.setGuideId(guideId);
		return incidentMapper.queryIncident(incident);
	}

}
